import 'package:flutter/widgets.dart';
import 'package:flutter_basic/basic/basic_controller.dart';
import 'package:flutter_basic/modules/customer/controller.dart';
import 'package:flutter_basic/modules/customer/customer_page.dart';
import 'package:flutter_basic/modules/home/controller.dart';
import 'package:flutter_basic/modules/home/home_page.dart';
import 'package:flutter_basic/modules/mine/controller.dart';
import 'package:flutter_basic/modules/mine/mine_page.dart';
import 'package:flutter_basic/modules/paper/controller.dart';
import 'package:flutter_basic/modules/paper/paper_page.dart';
import 'package:flutter_basic/modules/trans/controller.dart';
import 'package:flutter_basic/modules/trans/transaction_page.dart';
import 'package:get/get.dart';

class MainPageController extends BasicController{
  RxInt currentIndex = 0.obs;
  List<Widget> pages = <Widget>[];
  @override
  void onInit() {
    pages = _pages(this.tag);
    super.onInit();
  }
  @override
  void onReady() {

    super.onReady();
  }

  List<Map<String, String>> get bottomItems => <Map<String, String>>[
      {
        'title': '楼盘',
        'icon': 'ic_home.png',
        'active_icon': 'ic_home_selected.png',
      },
      {
        'title': '成交',
        'icon': 'ic_attach_money.png',
        'active_icon': 'ic_attach_money_selected.png',
      },
      {
        'title': '睇楼纸',
        'icon': 'ic_purchase_form.png',
        'active_icon': 'ic_purchase_form_selected.png',
      },
      {
        'title': '客户',
        'icon': 'ic_customer.png',
        'active_icon': 'ic_customer_selected.png',
      },
      {
        'title': '我的',
        'icon': 'ic_mine.png',
        'active_icon': 'ic_mine_selected.png',
      },
    ];

  List<Widget> _pages(String? tag) {

    if(pages.isEmpty){
      pages = <Widget>[
        HomePage.bind(HomeController(), tag: tag),
        TransactionPage.bind(TransactionPageController(), tag: tag),
        PaperPage.bind(PaperPageController(), tag: tag),
        CustomerPage.bind(CustomerPageController(), tag: tag),
        MinePage.bind(MineController(inTheTab: true), tag: tag),
      ];
    }
    return pages;
  }

  void indexChanged(int index) {
    currentIndex.value = index;
  }


}